<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@taglib uri="/typeUtil"  prefix="typeUtil"%>
<c:if test="${empty requestScope.rooms }">
		<center><h1>没有房间信息</h1></center>
</c:if>
<c:if test="${!empty requestScope.rooms }">
<!-- 资源管理模块 -->
<div role="tabpanel" class="tab-pane active" id="sour">
	<div class="check-div form-inline">
		<br><br>
	</div>
	<div class="data-div">
		<div class="row tableHeader">
			<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
				房间id
			</div>
			<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
				房间名称
			</div>
			<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
				房间类型
			</div>
			<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
				当前房型价格
			</div>
			<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
				当前房间价格
			</div>
			<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
				房间当前折扣
			</div>
			<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
				操作
			</div>
		</div>
		<div class="tablebody">
			<div id="collapseAccount" class="collapse in" aria-expanded="true">
				<c:forEach items="${requestScope.rooms }" var="room">
					<div class="row">
						<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 levl1 ">${room.id}
						</div>
						<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 levl1 ">${room.name}
						</div>
						<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 levl1">
							${typeUtil:getTypeName(room.typeId)}
						</div>
						<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 levl1">
							<span id='typePrice${room.id }'>${typeUtil:getTypePrice(room.typeId) }</span>
						</div>
	 					<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 levl1 ">
	 					<input class="form-control input-sm duiqi" type="text" value='${typeUtil:getTypePrice(room.typeId)*room.discount/100.0 }' id='price${room.id }'>
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 levl1">
						<input class="form-control input-sm duiqi" type="text" value='${room.discount }' id='discount${room.id }'>
						</div>
						
						<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 levl1">
	                  		<button type="button" class="btn btn-xs btn-xs btn-green" onclick="changePrice(${room.id })">修改价格</button>
	                  		<button type="button" class="btn btn-xs btn-xs btn-green" onclick="changeDiscount(${room.id })">修改折扣</button>
						</div>
					</div>
				</c:forEach>
			</div>
		</div>
	</div>
</div>
</c:if>
<!--页码块-->
<center>
	<a class="btn btn-xs btn-xs btn-green" onclick='jump("/hotel/finance/roomPricePage?page=1")'>#首页
	</a>
	<a class="btn btn-xs btn-xs btn-green" onclick='jump("/hotel/finance/roomPricePage?page=${currentPage==1?1:currentPage-1}")'>&lt;上一页
	</a>
	<a class="btn btn-xs btn-xs btn-green" onclick='jump("/hotel/finance/roomPricePage?page=${currentPage+1}")'>下一页&gt;
	</a>
</center>
<script src="/hotel/js/jumpUtil.js"></script>
<script>
	function changePrice(id){
		//alert()
		typePrice=eval($('#typePrice'+id).text())
		price=eval($('#price'+id).val())
		discount=Math.ceil(price/typePrice*100)
		data={'id':id,'discount':discount}
		if(confirm('您确定要修改价格为'+price+'(折扣修改为'+discount+')吗？')){
			$.post('/hotel/finance/changeRoomDiscount.do',data,function(str){
				res=eval('(' +str + ')')
				if(res.code==0){
					window.location.href="/hotel/system/mainPage"
				}else{
					alert(res.message)
				}
			})
		}else{
			return ;
		}
	}
	function changeDiscount(id){
		data={'id':id,'discount':$('#discount'+id).val()}
		if(confirm('您确定要修改折扣吗？')){
			$.post('/hotel/finance/changeRoomDiscount.do',data,function(str){
				res=eval('(' +str + ')')
				if(res.code==0){
					window.location.href="/hotel/system/mainPage"
				}else{
					alert(res.message)
				}
			})
		}else{
			return ;
		}
	}
</script>


